package com.xiaofengstu.mcams.exception;

import com.xiaofengstu.mcams.dto.BasicResultDTO;
import com.xiaofengstu.mcams.enums.RespStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.ResponseUtil;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author FengZeng
 * @Date 2022-05-11 00:03
 * @Description TODO
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

  @ExceptionHandler(value =BizException.class)
  public BasicResultDTO exceptionHandler(HttpServletRequest req, BizException e){
    log.error("异常！原因是:",e);
    return BasicResultDTO.fail(RespStatusEnum.INVALID_TOKEN);
  }
}
